package api

import (
	"fmt"
	"net/http"

	"gitee.com/yangwencheng/vblog/mvc/controllers"
	"gitee.com/yangwencheng/vblog/mvc/models"
	"github.com/gin-gonic/gin"
)

func HandelCreateBlog(ctx *gin.Context) {
	ctx.GetHeader("CROS_TOKEN")

	ctx.Query("id")
	userId, _ := ctx.GetPostForm("userId")
	//复制
	fmt.Println(userId)
	ins := &models.Blog{}
	ctx.BindJSON(ins)
	fmt.Println("实例数据", ins)

	controller := controllers.NewBlogController()
	err := controller.CreateBlog(ctx, ins)

	if err != nil {
		ctx.AbortWithError(http.StatusOK, err)
	} else {
		ctx.JSON(http.StatusOK, ins)
	}

}
